﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>修改密码</title>
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <div style="margin:5px">
        <fieldset class="layui-elem-field">
            <legend>修改密码</legend>
            <form class="layui-form" id="changePwd">
                <div class="layui-field-box"  style="border:5px">
                    <div class="layui-input-inline">
                        <label class="layui-form-label">原密码：</label>
                        <div class="layui-input-block">
                            <input type="password"  name="U_Password" class="layui-input" lay-verify="required" />
                            <input type="text" name="U_ID" value="@ViewBag.ID" hidden/>
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">新密码：</label>
                        <div class="layui-input-block">
                            <input type="password"  name="newU_Password" class="layui-input" lay-verify="required" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">确认密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="confifmU_Password" class="layui-input" lay-verify="required" />
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <div class="layui-btn-container">
                            <label class="layui-form-label"></label>
                            <button type="button" class="layui-btn layui-btn-sm" id="submit" lay-submit lay-filter="submitform"><i class="layui-icon">&#xe654;确定</i></button>
                            <button type="button" class="layui-btn layui-btn-sm" id="close"><i class="layui-icon">关闭</i></button>
                        </div>
                    </div>
                </div>
            </form>
        </fieldset>
    </div>
    <script>
        layui.use(['layer', 'form', 'jquery'], function () {
            var layer = layui.layer,
                form = layui.form,
                $ = layui.jquery;
             
            form.on('submit(submitform)', function (data) {
               var FormData = $('#changePwd').serializeArray();
                $.ajax({
                    url: '/Users/ChangePwd',
                    type: 'post',
                    data: FormData,
                    success: function (data) {
                        if (data.code == 0) {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            parent.layer.msg(data.msg, { icon: 1 })
                        } else {
                            layer.msg(data.msg, { icon: 2 })
                        }
                    },
                    error(data) {
                        layer.msg('网络错误，请重试', { icon: 2 })
                    }

                })
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });

            //$('#submit').click(function () {

            //})

            $('#close').click(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })
        })
    </script>
</body>
</html>
